﻿using MongoDB.Driver;
using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;
using Sustainalytics.Synchronization.Interface;
using Sustainalytics.Entities.ESGRatings;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.ESGAssessmentThresholdLogic
{
    public class EsgAssessmentThresholdCommand : SyncEsgCommand<EsgFocusThresholds>
    {
        private readonly IMongoCollection<EsgFocusThresholds> esgFocusThresholdCollection;

        public EsgAssessmentThresholdCommand(IMongoCollection<EsgFocusThresholds> esgFocusThresholdCollection, ILogger logger) : base(logger)
        {
            this.esgFocusThresholdCollection = esgFocusThresholdCollection;
        }

        protected override async Task<DeleteResult> DeleteAssociatedRecordsAsync(IEnumerable<Guid> companiesIds = null, Guid? additionalDiscriminator = null)
        {
            return await esgFocusThresholdCollection.DeleteManyAsync(Builders<EsgFocusThresholds>.Filter.Empty).ConfigureAwait(false);
        }

        protected override async Task InsertRecordsAsync(IEnumerable<EsgFocusThresholds> entities)
        {
            await esgFocusThresholdCollection.InsertManyAsync(entities).ConfigureAwait(false);
        }
    }
}
